//
//  StyleClass.m
//  Opper
//
//  Created by Le Dung on 4/13/13.
//  Copyright (c) 2013 LeDung. All rights reserved.
//

#import "StyleClass.h"


@implementation StyleClass



+(void)warningShow:(NSString*)title andMassage:(NSString *)massage
{
    UIAlertView *alert =[[UIAlertView alloc]initWithTitle:title message:massage delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
    [alert show];
    [alert release];
}



+(UIColor*)textBrowColor
{
    return [UIColor colorWithRed:135.0/255 green:135.0/255 blue:135.0/255 alpha:1 ];
}


+(NSMutableArray*)dataSimple
{
    NSMutableArray * array = [[NSMutableArray alloc]init];;
    for(int i = 0 ; i<12 ; i++)
    {
        NSString *detail =[NSString stringWithFormat:@"detail %d",i+1];
        [array addObject:detail];
        
    }
    return [array autorelease];
}
+(UIView*)listCollection :(UIView *)view andViewLocation:(UIView*)viewLocation andData:(NSMutableArray *)dataArray andTagSender:(NSInteger)tagSender
{
    
    CGRect frameList = viewLocation.frame;
    frameList.origin.y =frameList.origin.y+30;
    frameList.size.height=140;
    
    ListCollection *listCollection=[[ListCollection alloc]initWithFrame:frameList];
    
    listCollection.dataArray=dataArray;
    listCollection.indexPress=tagSender;
    
    
    
    [view addSubview:listCollection];
    
    listCollection.layer.borderColor=[UIColor colorWithRed:135.0/255 green:135.0/255 blue:135.0/255 alpha:1].CGColor;
    listCollection.layer.borderWidth=2.0;
    [listCollection setHidden:YES];
    return [listCollection autorelease];
}


+(void)createNavi:(UIViewController *)controller andTitle :(NSString *)controllTitle
{
    controller.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
    [controller.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"Navi.png"] forBarMetrics:UIBarMetricsDefault];

    UILabel *titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, -3, 100, 30)];
    titleLabel.text=controllTitle;
    titleLabel.textAlignment= NSTextAlignmentCenter;
    titleLabel.textColor=[UIColor colorWithRed:102.0/255 green:175.0/255 blue:55.0/255 alpha:1];
    titleLabel.backgroundColor =[UIColor clearColor];
    controller.navigationItem.titleView=titleLabel;
    
    [controller.navigationController.navigationBar addSubview:titleLabel];
    [titleLabel release];
}
+(void)currentScreen:(UIViewController *)current andDestination:(UIViewController *)destination andHideBackButton :(BOOL)isHide;
{
    [destination.navigationItem setHidesBackButton:YES];
    [current.navigationController pushViewController:destination animated:YES];
}

+(void)barButtonItemEdit :(UIViewController *)controller left:(BOOL)left right:(BOOL)right
{
    if(right)
    {
    UIButton *rightButton =[UIButton buttonWithType:UIButtonTypeCustom];
        [rightButton addTarget:controller action:@selector(rightPress) forControlEvents:UIControlEventTouchUpInside];
    rightButton.frame=CGRectMake(0  , 0, 50, 30);
    [StyleClass greenC:rightButton];
    rightButton.titleLabel.font=[UIFont systemFontOfSize:14];
    [rightButton setTitle:@"Wijzig" forState:UIControlStateNormal];
    controller.navigationItem.rightBarButtonItem =[[[UIBarButtonItem alloc]initWithCustomView:rightButton]autorelease ];
    }
    
    if(left)
    {
        UIButton *leftButton =[UIButton buttonWithType:UIButtonTypeCustom];
        [leftButton addTarget:controller action:@selector(leftPress) forControlEvents:UIControlEventTouchUpInside];
        
        leftButton.frame=CGRectMake(0  , 0, 30, 30);
        [leftButton setBackgroundImage:[UIImage imageNamed:@"PushBack.png"] forState:UIControlStateNormal];
               controller.navigationItem.leftBarButtonItem =[[[UIBarButtonItem alloc]initWithCustomView:leftButton]autorelease ];

    }
    
}
+(void)background:(UIView*)view
{
    view.backgroundColor=[UIColor colorWithRed:213.0/255 green:212.0/255 blue:202.0/255 alpha:1];
}

+(void)backgroundInblack:(UIView*)view
{
    view.backgroundColor=[UIColor colorWithRed:58.0/255 green:58.0/255 blue:56.0/255 alpha:1];
}

+(void)greenC:(UIView*)view
{
    view.backgroundColor=[UIColor colorWithRed:102.0/255 green:175.0/255 blue:55.0/255 alpha:1];
}

+(UIImage*)nGreen
{
    UIImage *unitImage=[[UIImage imageNamed:@"UnitGreen"] resizableImageWithCapInsets:UIEdgeInsetsMake(5, 10, 5, 10)];
    return unitImage;
}
+(UIImage*)nRed
{
    UIImage *unitImage=[[UIImage imageNamed:@"UnitRed"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
    return unitImage;
    
}
+(UIImage*)nGray
{
    UIImage *unitImage=[[UIImage imageNamed:@"UnitGray"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
    return unitImage;
    
}
+(UIImage*)nList
{
    UIImage *unitImage=[[UIImage imageNamed:@"ListButton"] resizableImageWithCapInsets:UIEdgeInsetsMake(3, 10, 3, 30)];
    return unitImage;
    
}
+(UIImage*)nText
{
    UIImage *unitImage=[[UIImage imageNamed:@"unitTextField"] resizableImageWithCapInsets:UIEdgeInsetsMake(3, 10, 3, 10)];
    return unitImage;
    
}

+(void)moveUp : (UIView *)view andYLocation:(NSInteger)yLocation
{
    CGRect newFrame ;
    newFrame= view.frame;
    newFrame.origin.y =newFrame.origin.y-yLocation;
    
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3];
    
    view.frame=newFrame;
    
    [UIView commitAnimations];
}

+(void)moveDown : (UIView *)view andYLocation:(NSInteger)yLocation
{
    CGRect newFrame ;
    newFrame= view.frame;
    newFrame.origin.y =newFrame.origin.y+yLocation;
    
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3];
    
    view.frame=newFrame;
    
    [UIView commitAnimations];
}


@end
